package org.ms.mtx.example.service.cannel;

import org.apache.commons.lang3.StringUtils;
import org.ms.mtx.example.service.ScoreService;
import org.springframework.stereotype.Service;

/**
 * 积分服务
 *
 * @author lry
 */
@Service
public class ScoreCancelService {

    public Boolean addScoreCancel(Integer tempScore, String exceptionMock) {
        if (StringUtils.isNotBlank(exceptionMock) && exceptionMock.equals(Thread.currentThread().getStackTrace()[1].getMethodName())) {
            throw new RuntimeException("模拟异常:" + Thread.currentThread().getStackTrace()[1].getMethodName());
        }

        System.out.println("回滚积分:积分从[" + ScoreService.score.get() + "]减少为[" + ScoreService.score.addAndGet(-tempScore) + "]");
        return true;
    }

}
